import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;
// 企业员工证书、外委人员证书

// 证书类别 页面内容 树
/* export function getPage(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    personnelType: queryParams.personnelType, //持证人类型 1-企业内部员工 2-外委人员 3-培训讲师
    personnelId: 0,//人员 id  没有指定人员时，默认传0
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize
  }
  return request({
    url: '/getCertificatesPage',
    method: 'post',
    data: data
  })
} */

// 证书类别 树(企业证书)
export function getCertCate() {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
  }
  return request({
    url: '/getCertCategory',
    method: 'post',
    data: data
  })
}

// 证书数据列表
export function booklistData(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
    keywords: queryParams.keywords,
    personnelType: queryParams.personnelType, //持证人类型 1-企业内部员工 2-外委人员 3-培训讲师
    personnelId: queryParams.personnelId, //人员 id  没有指定人员时，默认传0
    deptId: queryParams.deptId, //所属部门 id
    category: queryParams.category, //证书类别 id
    overdue: queryParams.overdue, //证书状态 0-未过期 1-已过期
    startTime: queryParams.startTime, //开始时间
    endTime: queryParams.endTime, //结束时间
    unitId: queryParams.unitId //工作单位 id
  }
  return request({
    url: '/getCertificateList',
    method: 'post',
    data: data
  })
}
// 证书数据添加
export function addCert(val) {
  const data = {
    projectContent: {
      ascriptionId: store.state.userInfo.ascriptionId, //机构 id
      certCode: val.certCode, //证书编号
      personnelType: val.personnelType, //持证人类型 1-企业内部员工 2-外委人员 3-培训讲师
      personnelId: val.personnelId, //持证人id
      personnelName: val.personnelName, //持证人
      certName: val.certName, //证书名称
      categoryId: val.categoryId, //证书类别
      categoryVal: val.categoryVal, //证书类别的文字值
      startTime: val.startTime, //发证日期
      endTime: val.endTime, //到期日期
      lssuingAuthority: val.lssuingAuthority, //发证机关
      certPic: val.certPic, //证书照片  多个图片之间用 , 隔开
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/addCertificate',
    method: 'post',
    data: data
  })
}

// 证书获取单条数据
export function getCertData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getCertificateData',
    method: 'post',
    data: data
  })
}

// 证书数据修改
export function updateCert(val) {
  const data = {
    projectContent: {
      theid: val.theid,
      certCode: val.certCode, //证书编号
      certName: val.certName, //证书名称
      categoryId: val.categoryId, //证书类别
      categoryVal: val.categoryVal, //证书类别的文字值
      startTime: val.startTime, //发证日期
      endTime: val.endTime, //到期日期
      lssuingAuthority: val.lssuingAuthority, //发证机关
      certPic: val.certPic, //证书照片  多个图片之间用 , 隔开
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/updateCertificate',
    method: 'post',
    data: data
  })
}

// 证书数据删除
export function delCert(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delCertificate',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultiData(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delMultipleCertificate',
    method: 'post',
    data: data
  })
}

// 下拉框
export function getSelect() {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
  }
  return request({
    url: '/getCertificateComboBox',
    method: 'post',
    data: data
  })
}